﻿using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;
using System.Web;

namespace SharePointExtendedDetailsFeature.Layouts.SharePointExtendedDetailsFeature
{
    public partial class Details : LayoutsPageBase
    {
        private ExtendedDetails _details;

        protected void Page_Load(object sender, EventArgs e)
        {
            _details = new ExtendedDetails();

            GetQueryStringParameters();

            if (_details.IsPageValid())
                _details.ProcessListItem();
            else
            {
                throw new SPException("Site URL or List ID was not provided.");
            }

        }

        /// <summary>
        /// Populates local variables from querystring parameters.
        /// </summary>
        private void GetQueryStringParameters()
        {
            // Pull the querystring parameters
            _details.SiteUrl = Page.Request.QueryString["SiteUrl"];
            _details.ListId = Page.Request.QueryString["ListId"];
        }
    }
}
